﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using WhittleList.RouteContraints;

namespace WhittleList
{
    // Note: For instructions on enabling IIS6 or IIS7 classic mode, 
    // visit http://go.microsoft.com/?LinkId=9394801

    public class MvcApplication : System.Web.HttpApplication
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            /*routes.MapRoute(
                "Project",                                              // Route name
                "{siteName}/project/{projectId}/{controller}/{action}/{id}",                           // URL with parameters
                new { controller = "project", action = "Index", id = "" },  // Parameter defaults
                new { siteName = new NoMatchConstraint("Account", "Home", "Item", "Project", "Section", "Site", "Stakeholder") }
            );*/

            routes.MapRoute(
            "Site",                                              // Route name
            "{siteName}/{controller}/{action}/{id}",                           // URL with parameters
            new { controller = "Site", action = "Index", id = "" },  // Parameter defaults
            new { siteName = new NoMatchConstraint("Account", "Home", "Item", "Project", "Section", "Site", "Stakeholder") }
            );

            routes.MapRoute(
            "Dashboard",                                              // Route name
            "Dashboard/{action}/{id}",                           // URL with parameters
            new { controller = "Dashboard", action = "Main", id = "" }  // Parameter defaults
            );

            routes.MapRoute(
                "Default",                                              // Route name
                "{controller}/{action}/{id}",                           // URL with parameters
                new { controller = "Home", action = "Index", id = "" }  // Parameter defaults
            );

        }

        protected void Application_Start()
        {
            ModelBinders.Binders[typeof(System.Data.Linq.Binary)] = new ModelBinder.LinqBinaryModelBinder();
            ModelBinders.Binders[typeof(WhittleList.Bll.Site)] = new ModelBinder.SiteModelBinder(); 
            
            
            RegisterRoutes(RouteTable.Routes);
        }
    }
}